var  e = require("../../utils/request");

Page({
    data: { 
        active: 0,
        list: [],
        tabledataList: [],
        tabledata1: [],
        tabledata2: [],
        tabledata3: [],
        tabledata4: [],
        tabledata5: []
    },
    onLoad: function(t) {
        this.setData({
            active: parseInt(t.active)
        });
    },
    onShow: function() {
        this.getlist();
    },
    onTagChange: function(t) {
        this.setData({
            active: parseInt(t.detail.name)
        }), this.getlist();
    },
    _loaddata: function() {
        switch (this.data.active) {
          case 1:
            var t = this.data.tabledataList.filter(function(t) {
                return parseInt(t.payState) < 20 && parseFloat(t.totalFee) > 0;
            });
            this.setData({
                tabledata1: t
            });
            break;

          case 2:
            var e = this.data.tabledataList.filter(function(t) {
                return 1 == parseInt(t.status);
            });
            this.setData({
                tabledata2: e
            });
            break;
 
        }
    },
    getlist: function() {
        var s = this;
        e.post1('getlist', {}).then(function(e) {
            e.success ? (e.data.forEach(function(e) {
                null == e.payStateName && (e.payStateName = "无需支付"), 
                null == e.totalFee && (e.totalFee = 0), parseInt(e.payState) < 2 ? e.toDo = "去付款" : 20 == parseInt(e.payState) && parseInt(e.status) >= 2 ? e.toDo = "" : e.toDo = "查看";
            }), s.setData({
                tabledataList: e.data
            }), s._loaddata()) : console.log("2");
        });
    }
});